<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
<html>
	<head>
		<title>Text Area Properties</title>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta content="noindex, nofollow" name="robots"> 
		<script src="../../dialog/common/fck_dialog_common.js" type="text/javascript"></script>
		<script type="text/javascript" src="../../dialog/fck_select/fck_select.js"></script>
		<script type="text/javascript" src="../../../../dwr/engine.js"></script>
		<script type="text/javascript" src="../../../../dwr/util.js"></script>
		<script type="text/javascript" src='../../../../dwr/interface/TableAction.js'></script>
		<script type="text/javascript" src='../../../../dwr/interface/ColumnAction.js'></script>
		<script type="text/javascript" src='../../../../dwr/interface/TableBean.js'></script>
		<script type="text/javascript" src='../../../../dwr/interface/ColumnBean.js'></script>
		<script language="javascript">
		var dialog	= window.parent ;
		var oEditor = dialog.InnerDialogLoaded() ;
		var FCKLang = oEditor.FCKLang ;
		// Gets the document DOM
		var oDOM = oEditor.FCK.EditorDocument ;		
		var oActiveEl = dialog.Selection.GetSelectedElement() ;
		window.onload = function (){
			oEditor.FCKLanguageManager.TranslatePage( document ) ;
			if ( oActiveEl && ((oActiveEl.tagName.toUpperCase() == 'INPUT' && oActiveEl.type == 'text')||oActiveEl.tagName == 'SELECT')  )
			{
				GetE('txtTable').value	= GetAttribute( oActiveEl, 'table' ); 
				GetE('dataFld').value	= GetAttribute( oActiveEl, 'dataFld' ) ;//
				GetE('dataSrc').value	= GetAttribute( oActiveEl, 'dataSrc' ) ;
				GetE('txtFontSize').value	= GetAttribute( oActiveEl, 'fontSize' ) ; 
				GetE('txtName').value	= oActiveEl.name ;
				view_sql();
			}
			else{
				oActiveEl = null ; 
			}
			dialog.SetOkButton( true ) ;
			dialog.SetAutoSize( true ) ; 
		}
		function Ok(){
			if(GetE('txtTable').value=="0"||GetE('txtTable').value==""){
				alert( "Table must be a require." ) ; 
				return false ;
			}else if(GetE('txtName').value=="0"||GetE('txtName').value==""){
				alert( "控件名称不能为空." ) ; 
				return false ;
			}else if(GetE('dataFld').value=="0"||GetE('dataFld').value==""){
				alert( "宏控件类型不能为空!" ) ; 
				return false ;
			}else if(GetE('dataFld').value=="SYS_LIST_SQL"&&(GetE('dataSrc').value=="")){
				alert( "SQL查询语句不能为空!" ) ; 
				return false ;
			}else if( isNaN( GetE('txtFontSize').value ) || GetE('txtFontSize').value < 0 )
			{
				alert( "字体大小为数字." ) ;
				GetE('txtFontSize').focus() ;
				return false ;
			}
			oEditor.FCKUndo.SaveUndoStep() ;
			if(GetE('dataFld').value.indexOf('SYS_LIST')>=0){
				oActiveEl = CreateNamedElement( oEditor, oActiveEl, 'SELECT', {name: GetE('txtName').value} ) ;
				SetAttribute( oActiveEl, 'table'	, GetE('txtTable').value ) ; 
				SetAttribute( oActiveEl, 'fontSize'		, GetE('txtFontSize').value ) ;
				SetAttribute( oActiveEl, 'dataFld', GetE('dataFld').value ) ;
				SetAttribute( oActiveEl, 'dataSrc', GetE('dataSrc').value ) ;
				var sText	= "{宏控件}" ;
				var sValue	= "{宏控件}" ;
				AddComboOption( oActiveEl, sText, sValue, oDOM ) ;
				//SetAttribute( oOption, 'selected', 'selected' ) ; 
				//oOption.selected = true ;
			}else{
				oActiveEl = CreateNamedElement( oEditor, oActiveEl, 'INPUT', {name: GetE('txtName').value, type:'text' } ) ;
				SetAttribute( oActiveEl, 'table'	, GetE('txtTable').value ) ;
				SetAttribute( oActiveEl, 'value'	, '{宏控件}' ) ;
				SetAttribute( oActiveEl, 'fontSize'		, GetE('txtFontSize').value ) ;
				SetAttribute( oActiveEl, 'dataFld', GetE('dataFld').value ) ;
				SetAttribute( oActiveEl, 'dataSrc', GetE('dataSrc').value ) ;
			}
			return true ;
		}
		function _$(id){
			return document.getElementById(id);
		}
		function updateTable(data){  
			DWRUtil.removeAllOptions('txtTable');
			DWRUtil.addOptions('txtTable',data,"id","tableName"); 
			if ( oActiveEl && ((oActiveEl.tagName.toUpperCase() == 'INPUT' && oActiveEl.type == 'text')||oActiveEl.tagName == 'SELECT')  )
			{
				GetE('txtTable').value	= GetAttribute( oActiveEl, 'table' );
			}
		}
		function view_sql()
		{ 
			var sqlArea=_$("sqlArea");
		   if(GetE('dataFld').value=="SYS_LIST_SQL"){
		      sqlArea.style.display="";
		   }
		   else{
		      sqlArea.style.display="none";
		   }
		}
		function tableChange(iflag,value){
			ColumnAction.dwrIndex(value,updateColumn(iflag));
		}
		function updateColumn(iflag){
			DWRUtil.removeAllOptions('txtName');
			return function(data){
				DWRUtil.addOptions('txtName',data,"id","columnName");
				if (iflag && oActiveEl && ((oActiveEl.tagName.toUpperCase() == 'INPUT' && oActiveEl.type == 'text')||oActiveEl.tagName == 'SELECT')  )
				{
					GetE('txtName').value		= oActiveEl.name ;
				}
			}
		}
		</script>
	</head>
	<body style="overflow: hidden">
	<table width="100%" style="height: 100%">
		<tr>
			<td align="center">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td>
							<span fcklang="DlgTableName">table</span>
						</td> 
						<td>
							<select id="txtTable" name="txtTable" style="width:150px;" onchange="javascript:tableChange(false,this.value);">
							</select> 
						</td> 
					</tr>
					<tr>
						<td>
							<span fcklang="DlgMacroName">name</span>
						</td> 
						<td>
							<select id="txtName" name="txtName" style="width:150px;">
							</select> 
						</td>
					</tr>
					<tr>
						<td>
							<span fcklang="DlgMacroType">type</span>
						</td> 
						<td>
							<select  name="dataFld" id="dataFld" onchange="javascript:view_sql();">
						        <option value="" style="background-color:#06c;color:#fff;">----单行输入框----</option>
						        <option value="SYS_DATE">当前日期，形如 1999-01-01</option>
						        <option value="SYS_DATE_YEAR">当前日期，形如 1999</option>
						        <option value="SYS_DATE_YEARANDMONTH">当前日期，形如 1999-01</option>
						        <option value="SYS_DATE_MONTHANDDAY">当前日期，形如 01-01</option>
						        <option value="SYS_TIME">当前时间 形如 12:30</option>
						        <option value="SYS_DATETIME">当前日期+时间</option>
						        <option value="SYS_WEEK">当前星期中的第几天，形如 星期一</option> 
						        <option value="" style="background-color:#06c;color:#fff;">----下拉菜单----</option>
						        <option value="SYS_LIST_SQL">来自SQL查询语句的列表</option>
						       </select>
						</td> 
					</tr>
					<tr id="sqlArea">
						<td>
							<span fcklang="DlgMacroQuery">query</span>
						</td>
						<td>
							<textarea name="dataSrc" id="dataSrc" class="SmallInput" style="width:150px;" cols="28" rows="4" title="如宏控件类型选择来自SQL查询语句，则填写"></textarea>
						</td>
						
					</tr>
					<tr> 
						<td>
							<span fcklang="DlgMacroFont">font size</span>
						</td>
						<td>
							<input id="txtFontSize" name="txtFontSize" type="text" size="2"  style="width:150px;"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<script type="text/javascript">
		TableAction.dwrIndex("",updateTable);
		oEditor.FCKLanguageManager.TranslatePage(document) ;
		if ( oActiveEl && ((oActiveEl.tagName.toUpperCase() == 'INPUT' && oActiveEl.type == 'text')||oActiveEl.tagName == 'SELECT')  )
		 {
			tableChange(true,GetAttribute( oActiveEl, 'table' ));
		}
	</script>
	</body>
</html>
